package com.ryan.dispatcher.comp;

import com.ryan.dispatcher.ResourceTable;
import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.agp.utils.TextAlignment;

import static ohos.agp.components.ComponentContainer.LayoutConfig.MATCH_PARENT;

public class InPagerFraction extends Fraction {

    private int index;
    private Text text;

    public InPagerFraction(int index) {
        this.index = index;
    }

    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        text = new Text(getContext());
        text.setLayoutConfig(new ComponentContainer.LayoutConfig(MATCH_PARENT, MATCH_PARENT));
        text.setTextSize(90);
        text.setTextAlignment(TextAlignment.CENTER);
        return text;
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        text.setText("I'm fraction" + index);
    }
}
